flowchart LR
A["MLE"]
B["βₖ - 4σ"]
C["βₖ - 2σ"]
D["βₖ"]
E["βₖ + 2σ"]
F["βₖ + 4σ"]
A --> B
A --> C
A --> D
A --> E
A --> F
ENCI707: Engineering Demand and Policy Analysis
\[ Pr(Y_i=1\mid X_i) = \frac{\exp(X_i\beta)} {1+\exp(X_i\beta)} \] \[ l(\beta\mid \mathbf Y,\mathbf X) = \prod_{i=1}^{n} Pr(Y_i=1\mid X_i)^{Y_i} \Bigl(1-Pr(Y_i=1\mid X_i)\Bigr)^{1-Y_i} \] \[ L(\beta\mid \mathbf Y,\mathbf X) = \sum_{i=1}^{n} Y_i\log Pr(Y_i=1\mid X_i) + (1-Y_i)\log\left(1-Pr(Y_i=1\mid X_i)\right) \]
Substituting the logit probability:
\[ L(\beta) = \sum_{i=1}^{n} \left[ Y_i\log \left( \frac{\exp(X_i\beta)} {1+\exp(X_i\beta)} \right) + (1-Y_i) \log \left( \frac{1} {1+\exp(X_i\beta)} \right) \right] \]
After simplification:
\[ L(\beta) = \sum_{i=1}^{n} \left[ Y_iX_i\beta - \log\left(1+\exp(X_i\beta)\right) \right] \]
We now have a likelihood function. Goal: \(\max_{\beta} L(\beta)\)
Take derivatives and search for the maximum
Some good and bad news…
\[ L(\beta) = \sum_{i=1}^{n} \left[ Y_iX_i\beta - \log(1+\exp(X_i\beta)) \right] \]
Score function: \[ \frac{\partial L(\beta)} {\partial \beta} = \sum_{i=1}^{n} X_i \left( Y_i - \frac{\exp(X_i\beta)} {1+\exp(X_i\beta)} \right) \]
While there is not an analytic solution, if there is a maximum where \(\hat{\beta}\) satisfies \(\frac{\partial L(\hat{\beta})}{\partial \beta} = 0\), then there are sets of conditions such that \[ \lim_{n\to\infty} Pr\!\left( \|\hat\beta_n-\beta_0\|>\varepsilon \right) = 0 \text{ (weak consistency)} \] \[ \sqrt n (\hat\beta_n-\beta_0) \overset{d}{\to} N \left( 0, -\mathbb E \left[ \frac{\partial^2L(\beta_0)} {\partial\beta\partial\beta'} \right]^{-1} \right) \text{ (asymptotic normality)} \]
The challenge is that the conditions for when this is satisfied vary from problem to problem
Update rule: \[ \theta_{k+1} = \theta_k - \left[ \frac{\partial^2Q(\theta_k)} {\partial\theta\partial\theta'} \right]^{-1} \frac{\partial Q(\theta_k)} {\partial\theta} \]
Then:
\[ \theta_{k+1} = \theta_k - \lambda_k A_k \frac{\partial Q}{\partial\theta}(\theta_k) \]
Newton-Raphson is a special case:
\[ \lambda_k=1 \]
\[ A_k = \left[ \frac{\partial^2L(\theta_k)} {\partial\theta\partial\theta'} \right]^{-1} \]
Choose a direction, then choose how far to move:
\[ \lambda_k = \arg\min_{\lambda} Q(\theta_k+\lambda\tilde d_k) \]
Simplest choice (steepest ascent):
\[ A_k=I \]
Given a direction \(d\), define
\[ \lambda^{*} = \arg\min_\lambda Q(\lambda) \]
\[\lambda_{k+1} = \lambda_k - \frac{Q'(\lambda_k)} {Q''(\lambda_k)} \]
Repeat until: \(|\lambda_{k+1}-\lambda_k|\) is sufficiently small
Drawback: Requires evaluation of the second derivative
Requirements:
\[ [\lambda_l,\lambda_h] \]
Choose:
\[ \lambda_{m1} = \lambda_l + 0.392(\lambda_h-\lambda_l) \]
\[ \lambda_{m2} = \lambda_l + 0.618(\lambda_h-\lambda_l) \]
Given the four points, can check two conditions:
If \(Q(\lambda_{m2})>Q(\lambda_{m1})\) then the minimizer lies in \[ [\lambda_l,\lambda_{m2}] \]
If \(Q(\lambda_{m2})<Q(\lambda_{m1})\) then the minimizer lies in \[ [\lambda_{m1},\lambda_h] \]
Repeat until convergence
MSL steps:
For mixed logit \[SL = \sum_{n=1}^N \sum_{j=1}^J (Y_j=i) ln(\hat{Pr(i)})\]
For parameter \(\beta_k\):
This produces a profile likelihood
Interpretation
✅ Smooth decline away from the optimum = Likelihood behaves as expected
❌ Another region has a higher log-likelihood = Evidence of a superior local optimum nearby
flowchart LR
A["MLE"]
B["βₖ - 4σ"]
C["βₖ - 2σ"]
D["βₖ"]
E["βₖ + 2σ"]
F["βₖ + 4σ"]
A --> B
A --> C
A --> D
A --> E
A --> F
Using a Swiss route-choice stated-preference dataset:
Latent Class Model
Initial solution:
\[ LL=-1578.3 \]
Profile likelihood search identified:
Mixed Logit Model
Initial solution:
\[ LL=-1405.2 \]
Profile likelihood search identified:
Key Finding
Suppose we need the gradient of a loss function:
\[ L(\theta)=\sum_i\left(y_i-\hat y_i(\theta)\right)^2 \]
for optimization algorithms such as:
Three options
Consider
\[ f(x)=\sin(x^2+1) \]
Break the computation into elementary steps:
\[ v_1=x \]
\[ v_2=v_1^2 \]
\[ v_3=v_2+1 \]
\[ v_4=\sin(v_3) \]
The chain rule gives
\[ \frac{df}{dx} = \frac{\partial v_4}{\partial v_3} \frac{\partial v_3}{\partial v_2} \frac{\partial v_2}{\partial v_1} \frac{\partial v_1}{\partial x} \]
Result:
\[ \frac{df}{dx} = \cos(x^2+1)\,2x \]
AD applies the chain rule automatically to every elementary operation
Track both the value and derivative simultaneously
For
\[ f(x)=\sin(x^2+1) \]
with \(x=2\):
| Variable | Value | Derivative |
|---|---|---|
| \(v_1=x\) | \(2\) | \(1\) |
| \(v_2=v_1^2\) | \(4\) | \(2v_1(1)=4\) |
| \(v_3=v_2+1\) | \(5\) | \(4\) |
| \(v_4=\sin(v_3)\) | \(\sin(5)\) | \(\cos(5)\times4\) |
Each operation propagates:
\[ (\text{value},\text{derivative}) \rightarrow (\text{new value},\text{new derivative}) \]
Most efficient when: Few inputs & many outputs
For a scalar objective:
\[ L=f(\theta_1,\theta_2,\ldots,\theta_n) \]
We first compute all intermediate values:
\[ \theta \rightarrow v_1 \rightarrow v_2 \rightarrow \cdots \rightarrow L \]
Then work backward:
\[ \frac{\partial L}{\partial v_i} = \frac{\partial L}{\partial v_{i+1}} \frac{\partial v_{i+1}}{\partial v_i} \]
flowchart TD
X["x"]
V2["x²"]
V3["+1"]
V4["sin(.)"]
F["f(x)"]
X --> V2
V2 --> V3
V3 --> V4
V4 --> F
F -.->|"1"| V4
V4 -.->|"cos(v₃)"| V3
V3 -.->|"1"| V2
V2 -.->|"2x"| X
classDef node fill:#dbeafe,stroke:#2563eb,stroke-width:2px;
class X,V2,V3,V4,F node;
For
\[ f(x)=\sin(x^2+1) \]
Forward pass
Reverse pass
\[ \frac{df}{dx} = 2x\cos(x^2+1) \]
Traditional View
Key Insight
Iterative feedback is required until demand and network conditions are consistent
Automatic Differentiation View
flowchart LR
C["Travel Costs"]
D["Mode & Route Choice"]
X["Path Flows"]
V["Link Volumes"]
T["Travel Times"]
C --> D
D --> X
X --> V
V --> T
T --> C
classDef node fill:#dbeafe,stroke:#2563eb,stroke-width:2px;
class C,D,X,V,T node;
The entire transportation system can be viewed as a computational graph
Calibration chooses model parameters
\[ \theta=(\beta_{\text{time}},\beta_{\text{cost}},\ldots) \]
to minimize a calibration loss:
\[ L(\boldsymbol{\theta}) = \text{Observed Data} - \text{Model Predictions} \]
flowchart LR
B["Parameters<br>θ"]
M["Transportation<br>Model"]
L["Loss<br>L(θ)"]
B --> M
M --> L
L -. "Gradients" .-> B
classDef blue fill:#dbeafe,stroke:#2563eb;
classDef red fill:#fee2e2,stroke:#dc2626;
class B,M blue;
class L red;
Key takeaway: Treat the transportation model as a computational graph and use backpropagation to obtain gradients for efficient calibration